package com.example.micro.mysql.deadlock.service.impl;

import com.example.micro.mysql.deadlock.service.InjectionAService;
import com.example.micro.mysql.deadlock.service.InjectionCService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class InjectionCServiceImpl implements InjectionCService {

    //如果此处引用了injectionAService ，就会发生循环依赖问题，
    //因为此处产生了循环依赖，所以在InjectionCService createBean 阶段，就会先去实例化injectionAService
    //但是此时还没有进行@Async 代理，@Async的原理 AbstractAdvisingBeanPostProcessor
    //说白了就是初始化前后置处理器，但此时injectionAService 已经创建了一个初始bean
    //所以会出现不一致的冲突
    @Resource
    private InjectionAService injectionAService;

    @Override
    public void print() {
        System.out.println("this is C");
        injectionAService.print();
    }

}
